package com.pattern.once.clainOfResponsbility;

public abstract class AbstractClainLogger {

    public static final Integer debug = 1;
    public static final Integer info = 2;
    public static final Integer warn = 3;
    public static final Integer error = 4;

    private int level;

    protected AbstractClainLogger nextClainLogger;

    public void exeuct(Logger logger){

        if (logger.getLevel() <= level){
            this.writeMessage(logger.getMessage());
            return;
        }
        if (nextClainLogger != null){
            this.nextClainLogger.exeuct(logger);
        }else {
            System.out.println("请求无法处理");
        }

    }


    protected abstract void writeMessage(String message);


    public void setLevel(int level) {
        this.level = level;
    }

    public void setNextClainLogger(AbstractClainLogger nextClainLogger) {
        this.nextClainLogger = nextClainLogger;
    }
}
